
#include "ipfe_for_HOG.h"

// [*] CFeatureFactory_HOG

CFeatureFactory_HOG::CParameters CFeatureFactory_HOG::Parameters;

CImagePositionFeatureExtractor* CFeatureFactory_HOG::GenerateIPFE()
{
	CImageFilterBank* pIFB = new CImageFilterBank();
	pIFB->myInit();

	CImageFilter_RGB* pFilter_RGB = pIFB->pBasicFilter_RGB;

	CImageFilter_Func_Sqrt* pFilter_Func_Sqrt = new CImageFilter_Func_Sqrt();
	pFilter_Func_Sqrt->PushBackInputResponse(pFilter_RGB, 0);
	pFilter_Func_Sqrt->PushBackInputResponse(pFilter_RGB, 1);
	pFilter_Func_Sqrt->PushBackInputResponse(pFilter_RGB, 2);
	pIFB->PushBackFilter(pFilter_Func_Sqrt);

	CImageFilter_Gradient* pFilter_Gradient = new CImageFilter_Gradient(0.0, false);
	pFilter_Gradient->PushBackInputResponse(pFilter_Func_Sqrt, 0);
	pFilter_Gradient->PushBackInputResponse(pFilter_Func_Sqrt, 1);
	pFilter_Gradient->PushBackInputResponse(pFilter_Func_Sqrt, 2);
	pIFB->PushBackFilter(pFilter_Gradient);

	// Setting Response Output

	pFilter_Gradient->PushBackOutput(0);			// Mag
	pFilter_Gradient->PushBackOutput(1);			// Ori

	// Finish Filter Bank Initialization

	pIFB->GetOutputDimension(true);

	// IFB Done;

	C_IPFC_ImageFilterBankOwner* pIFBO = new C_IPFC_ImageFilterBankOwner(pIFB, Parameters.ImageExtent, false);
	int iiList[2];
	iiList[0] = 0;
	iiList[1] = 1;
	pIFBO->PushBackResponseUser(new C_IPFC_ResponseUser_2D_RectHistogram(Parameters.DescriptorConfig, Parameters.ResponseConfig), iiList);

	CCompositeIPFC* pCompositeIPFC = new CCompositeIPFC();
	pCompositeIPFC->PushBack(pIFBO);

	CImagePositionFeatureExtractor* ret = new CBasicIPFE(pCompositeIPFC);

	return ret;
}

CImagePyramidPositionFeatureExtractor* CFeatureFactory_HOG::GenerateIPPFE(int CacheSize)
{
	CImagePositionFeatureExtractor* pIPFE = GenerateIPFE();
	CImagePyramidPositionFeatureExtractor* ret = new CImagePyramidPositionFeatureExtractor(pIPFE, CacheSize);
	return ret;
}

//// [*] C_IPPFE_Factory_HOG
//
//C_IPPFE_Factory_HOG::CParameters C_IPPFE_Factory_HOG::Parameters;
//
//CImagePositionFeatureExtractor* C_IPPFE_Factory_HOG::GenerateIPFE()
//{
//	CCompositeIPFC* pCompositeIPFC = new CCompositeIPFC();
//
//	//pCompositeIPFC->PushBack(
//	//	new CRectHistogram_of_2D_Response_IPFC(
//	//		new _C_ImageFilter_Gradient(_C_ImageFilter_Gradient::SOURCE_MODE_RGB, _C_ImageFilter_Gradient::PRE_MODE_SQRT, 3, 0.0, false),
//	//		&Parameters.ResponseConfig, &Parameters.DescriptorConfig
//	//		)
//	//	);
//
//	CImagePositionFeatureExtractor* ret = new CBasicIPFE(pCompositeIPFC, Parameters.ImageExtent);
//
//	return ret;
//}
//
//CImagePyramidPositionFeatureExtractor* C_IPPFE_Factory_HOG::GenerateIPPFE(int CacheSize)
//{
//	CImagePositionFeatureExtractor* pIPFE = GenerateIPFE();
//	CImagePyramidPositionFeatureExtractor* ret = new CImagePyramidPositionFeatureExtractor(pIPFE, CacheSize);
//	return ret;
//}

